import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/styles/index.scss'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI)
Vue.config.productionTip = false
// 设置路由守卫
router.beforeEach((to, from, next) => {
  let mytoken = localStorage.getItem('mytoken')
  if (mytoken) {
    next()
  } else {
    to.name !== 'login' ? next('/login') : next()
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
